Ext.define('BenBen.modules.system.organization.UserGrid', {
    extend : 'BenBen.common.BaseGrid',
    requires: [
       'Ext.ux.form.SearchField',
       'BenBen.modules.system.role.RoleDistributeWindow'
    ],
    layout : 'border',
    border : false,
	initComponent : function() {
		var me = this;
        var modelFields = ['userId','username','departmentName', 'phone', 'email','state'];
        
        var columns = [{
            dataIndex: 'userId',
            text: '账号'
        },{
        	dataIndex: 'username',
        	text: '姓名'
        },{
            dataIndex: 'departmentName',
            text: '部门'
        },{
        	dataIndex: 'phone',
        	text: '手机'
        },{
        	dataIndex: 'email',
        	text: 'Email'
        },{
            dataIndex: 'state',
            text: '状态',
            renderer: function (value) {
                if (value == '1') {
                    return "模块";
                }else if (value == '2') {
                    return "按钮";
                } 
            }
        }];
        
        var tbarItems = [{
            text : '分配角色',
            iconCls : 'gridupdate',
            handler :function(){
            	var record = me.getSeletedRecord();
                if(record != null){
                	var roleWindow = Ext.create('BenBen.modules.system.role.RoleDistributeWindow',{
                		userRecord : record
            		});
                	
                	roleWindow.show();
                }
            	
            }
        },{
            text : '导出微信人员',
            iconCls : 'gridupdate',
            handler :function(){
            	
            	window.location.href = 'system/user/wx';
            	
            }
        }];

        Ext.apply(this,{
			border : false,
			isLoad : false,
			columns : columns,
			modelFields : modelFields,
			tbarDefaultItems : 'search',
			tbarItems : tbarItems,
			config : {
				pageSize : 30,
				url : 'system/user'
			},
			height: 520
		});

		this.callParent(arguments);
	}
});